    <template>
      <!-- 编辑界面 -->
      <el-dialog :title="title" :visible.sync="isVisible" width="30%" @click="closeDialog(false)" @close="closeDialog(false)">

            <el-form label-width="120px"  :model="editForm" :rules="rules" ref="editForm">
             <!-- <el-form-item label="是否发布" prop="isActive">
                <el-checkbox v-model="editForm.isActive"></el-checkbox>
              </el-form-item>
-->
              <el-form-item label="栏目名称" prop="name">
                <el-input size="small" v-model="editForm.name" auto-complete="off" placeholder="请输入广告名称"></el-input>
              </el-form-item>
              <el-form-item label="父级编号" prop="parentId">
                <el-input size="small" v-model="editForm.parentId" auto-complete="off" placeholder="父级编号"></el-input>
              </el-form-item>


            </el-form>

            <div slot="footer" class="dialog-footer" style="text-align: right">
              <el-button size="small" @click="closeDialog(false)">取消</el-button>
              <el-button size="small" type="primary"  class="title" @click="submitForm('editForm')">保存</el-button>
            </div>


      </el-dialog>

    </template>

<script>
  import {cmsApi} from "../../api/baseApi";
  import axios from "axios"
    import { quillEditor } from "vue-quill-editor";
    import "quill/dist/quill.core.css";
    import "quill/dist/quill.snow.css";
    import "quill/dist/quill.bubble.css";

    export default {
        name: 'NewsItemCategoryEdit',
        componentName: 'NewsItemCategoryEdit',
        components:{quillEditor},
        props: {
            dialogVisible:false,
            rowData:{}
        },
        data() {
            return {
                title: '添加',
                content:"",
                //tab-1
                isVisible: this.dialogVisible,
                editForm: {},
                rules: {
                    name: [
                        { required: true, message: '请输入广告名称', trigger: 'blur' }
                    ],
                    parentId: [{ required: true, message: '请选择父级节点', trigger: 'blur' }],
                },


            };
        },
        methods:{

            // 关闭编辑、增加弹出框
            closeDialog(saveOrNot) {
                this.isVisible = false;
                this.$emit('onDialogClose',saveOrNot);
            },

            //提交基本信息
            submitForm(editData) {
                this.$refs[editData].validate(valid => {
                    if (valid) {
                        axios.post(cmsApi+"news-item-category/save",this.editForm)
                            .then(res=>{
                               this.closeDialog(true);
                            }).catch(err=>{
                            this.$message.error('公司保存失败，请稍后再试！'+err)
                        })

                    } else {
                        return false
                    }
                })
            },
        },
        watch: {

            //监听窗口变化，通知母版
            dialogVisible: {
                handler: function (val) {
                    if (val) {
                        this.isVisible = true;
                        this.editForm = this.rowData;
                        if(this.rowData.id!=undefined && this.rowData.id>0){
                            this.title="编辑";
                        }
                        else{
                            this.title = "添加";
                        }
                    }
                }
            }

        }
    };
</script>

    <style scoped>
      .avatar{
        max-width: 150px;
        max-height: 150px;
      }
    </style>

